package com.tangyuan.video.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tangyuan.dto.VideoPublisherDto;
import com.tangyuan.feignapis.video.IVideoFeignClient;
import com.tangyuan.model.Video;
import com.tangyuan.video.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/feignApi/video")
public class VideoFeignClient implements IVideoFeignClient {

    @Autowired
    private VideoService videoService;

    @GetMapping("/getVideoInfo")
    @Override
    public List<Video> getVideoInfo(
            @RequestParam(value = "userId") Long userId,
            @RequestParam(value = "name") String name,
            @RequestParam(value = "pageNum") Integer pageNum,
            @RequestParam(value = "pageSize") Integer pageSize) {
        return videoService.getVideoInfo(userId,name,pageNum,pageSize);
    }

    @Override
    @GetMapping("/getVideoByIds")
    public List<Video> getVideoByIds(List<Long> ids, Long userId) {
        return videoService.getVideoByIds(ids,userId);
    }
    /**
     * 返回当前用户是否点赞、收藏、评论、的Video
     * @param videoId
     * @param userId
     * @return
     */
    @GetMapping("/getVideoById/{videoId}/{userId}")
    @Override
    public Video getByVideoId(@PathVariable Long videoId,@PathVariable Long userId) {
        return videoService.getVideoById(videoId,userId);
    }

    @GetMapping("/getVideoById/{videoId}")
    @Override
    public Video getByVideoId(@PathVariable Long videoId) {
        return videoService.getById(videoId);
    }

    @GetMapping("/getMyVideoByUserId/{myUserId}/{userId}/{pageNum}/{pageSize}")
    @Override
    public List<Video> getMyVideoByUserId(@PathVariable Long myUserId,@PathVariable Long userId, @PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
        return videoService.getMyVideoByUserId(myUserId,userId,pageNum, pageSize);
    }

    @GetMapping("/getVideoThumpNum/{userId}")
    @Override
    public Long getVideoThumpNum(@PathVariable("userId") Long userId) {
        return videoService.getVideoThumpNum(userId);
    }

    @GetMapping("/getMyCollectVideo/{userId}/{pageNum}/{pageSize}")
    @Override
    public List<Video> getMyCollectVideo(@PathVariable Long userId, @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        return videoService.getMyCollectVideo(userId,pageNum, pageSize);
    }

    @GetMapping("/getMyTrumpVideo/{userId}/{pageNum}/{pageSize}")
    @Override
    public List<Video> getMyTrumpVideo(@PathVariable Long userId, @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        return videoService.getMyTrumpVideo(userId,pageNum, pageSize);
    }
    @GetMapping("/getMyActionVideo/{userId}/{pageNum}/{pageSize}")
    @Override
    public Page<Video> getMyActionVideo(@PathVariable Long userId, @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        return videoService.getMyActionVideo(userId,pageNum, pageSize);
    }

    @PostMapping("/updateUserVideoMessage")
    @Override
    public void updateUserVideoMessage(@RequestBody VideoPublisherDto videoPublisherDto) {
        videoService.updateUserVideoMessage(videoPublisherDto);
    }
}
